<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\index\logic;


/**
 * Index基础逻辑
 */
class Payment extends IndexBase
{
	public function wxpay(){
		$order=array();
		$res=$this->servicePay->driverWxpay->pay($order,'h5',2);
		return $res;
	}
	public function zfbnotify(){
		$res=$this->servicePay->driverAlipay->notify();
		if($res){
			$str=substr($_POST['out_trade_no'],0,2);
			if($str == 'ms'){
				$stat=db('series_order')->where('order_sn',$_POST['out_trade_no'])->value('stat');
				if($stat != 1){
					getSeries($_POST['out_trade_no']);
				}
			}else{
				$stat=db('money_order')->where('order_sn',$_POST['out_trade_no'])->value('stat');
				if($stat != 1){
					getMDC($_POST['out_trade_no']);
				}
			}
		}
	}
	public function wxNotify(){
		$res=$this->servicePay->driverWxpay->notify();
		if($res){
			$xmlData = file_get_contents('php://input');
			$data = json_decode(json_encode(simplexml_load_string($xmlData, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
			$str=substr($data['out_trade_no'],0,2);
			if($str == 'ms'){
				$stat=db('series_order')->where('order_sn',$data['out_trade_no'])->value('stat');
				if($stat != 1){
					getSeries($_POST['out_trade_no']);
				}
			}else{
				$stat=db('money_order')->where('order_sn',$data['out_trade_no'])->value('stat');
				if($stat != 1){
					getMDC($_POST['out_trade_no']);
				}
			}

		}
	}
}
